{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-07-01T06:25:29.387402Z",
     "start_time": "2025-07-01T06:25:03.437970Z"
    }
   },
   "source": [
    "import pandas as pd\n",
    "COLUMNS = [\"uid\", \"datetime\", \"lng\", \"lat\", \"type\"]\n",
    "df = pd.read_csv('./trajectory01.tsv', sep='\\t',header=None, names=COLUMNS, skipfooter=1, engine='python')\n"
   ],
   "outputs": [],
   "execution_count": 10
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-05-29T15:36:16.985076Z",
     "start_time": "2025-05-29T15:36:16.976720Z"
    }
   },
   "cell_type": "code",
   "source": "",
   "id": "e6b9b083a64c2047",
   "outputs": [],
   "execution_count": 22
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-07-01T06:27:38.604816Z",
     "start_time": "2025-07-01T06:27:38.589093Z"
    }
   },
   "cell_type": "code",
   "source": "print(df.shape)",
   "id": "ccc506ec81a2dd88",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(9198099, 5)\n"
     ]
    }
   ],
   "execution_count": 11
  },
  {
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-07-01T06:27:39.998754Z",
     "start_time": "2025-07-01T06:27:39.982928Z"
    }
   },
   "cell_type": "code",
   "source": "print(df.head())",
   "id": "fc50602cc84a2536",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   uid             datetime        lng        lat  type\n",
      "0   40  2017-01-12 03:00:00  139.60923  35.641745    99\n",
      "1   40  2017-01-12 04:00:00  139.60923  35.641745    99\n",
      "2   40  2017-01-12 05:00:00  139.60923  35.641745    99\n",
      "3   40  2017-01-12 06:00:00  139.60923  35.641745    99\n",
      "4   40  2017-01-12 07:00:00  139.60923  35.641745    99\n"
     ]
    }
   ],
   "execution_count": 12
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-07-01T06:27:43.163469Z",
     "start_time": "2025-07-01T06:27:43.032386Z"
    }
   },
   "cell_type": "code",
   "source": "df.drop(\"type\", axis=1, inplace=True)",
   "id": "b57b95c2534a3957",
   "outputs": [],
   "execution_count": 13
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-07-01T06:27:49.511047Z",
     "start_time": "2025-07-01T06:27:47.512330Z"
    }
   },
   "cell_type": "code",
   "source": "df[\"datetime\"] = pd.to_datetime(df[\"datetime\"])",
   "id": "1432944fbd947737",
   "outputs": [],
   "execution_count": 14
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-07-01T06:27:51.806654Z",
     "start_time": "2025-07-01T06:27:51.790952Z"
    }
   },
   "cell_type": "code",
   "source": "print(df.head())",
   "id": "250698ea51352f51",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   uid            datetime        lng        lat\n",
      "0   40 2017-01-12 03:00:00  139.60923  35.641745\n",
      "1   40 2017-01-12 04:00:00  139.60923  35.641745\n",
      "2   40 2017-01-12 05:00:00  139.60923  35.641745\n",
      "3   40 2017-01-12 06:00:00  139.60923  35.641745\n",
      "4   40 2017-01-12 07:00:00  139.60923  35.641745\n"
     ]
    }
   ],
   "execution_count": 15
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-07-01T06:28:12.803841Z",
     "start_time": "2025-07-01T06:27:53.888268Z"
    }
   },
   "cell_type": "code",
   "source": "df.to_csv('../trajectory.csv', sep=',' )",
   "id": "d1b4688dffa10a74",
   "outputs": [],
   "execution_count": 16
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-07-01T05:59:02.571268Z",
     "start_time": "2025-07-01T05:59:02.555591Z"
    }
   },
   "cell_type": "code",
   "source": "print(df.shape)",
   "id": "9cb723fa465c4404",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(9198099, 4)\n"
     ]
    }
   ],
   "execution_count": 8
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-05-25T14:46:41.040233Z",
     "start_time": "2025-05-25T14:45:16.924597Z"
    }
   },
   "cell_type": "code",
   "source": "",
   "id": "691b5706049b756d",
   "outputs": [],
   "execution_count": 10
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-05-27T07:53:55.091611Z",
     "start_time": "2025-05-27T07:53:54.931540Z"
    }
   },
   "cell_type": "code",
   "source": [
    "import pandas as pd\n",
    "\n",
    "df = pd.read_csv('./traj_train.csv', nrows = 30000)\n"
   ],
   "id": "dd4b6d6beb916dbc",
   "outputs": [],
   "execution_count": 9
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-05-29T15:34:16.779829Z",
     "start_time": "2025-05-29T15:34:16.671445Z"
    }
   },
   "cell_type": "code",
   "source": "",
   "id": "7012a007e79800dc",
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'df' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001B[1;31m---------------------------------------------------------------------------\u001B[0m",
      "\u001B[1;31mNameError\u001B[0m                                 Traceback (most recent call last)",
      "Cell \u001B[1;32mIn[19], line 1\u001B[0m\n\u001B[1;32m----> 1\u001B[0m df[\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mdatetime\u001B[39m\u001B[38;5;124m\"\u001B[39m] \u001B[38;5;241m=\u001B[39m pd\u001B[38;5;241m.\u001B[39mto_datetime(\u001B[43mdf\u001B[49m[\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mdatetime\u001B[39m\u001B[38;5;124m\"\u001B[39m])\n",
      "\u001B[1;31mNameError\u001B[0m: name 'df' is not defined"
     ]
    }
   ],
   "execution_count": 19
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-05-27T07:54:06.815462Z",
     "start_time": "2025-05-27T07:54:06.712895Z"
    }
   },
   "cell_type": "code",
   "source": "df.to_csv(\"./traj_train1.csv\", index=False)",
   "id": "2161ad6d714a9164",
   "outputs": [],
   "execution_count": 10
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
